/*
day334 
2020.7.27 
*/
#include<iostream>
#include<unordered_map>
#include<string>
#include<vector>
#include<cstdlib> 
using namespace std;


class Solution {
	struct Node{
		int max;
		int min;
		Node ():max(INT_MIN),min(INT_MAX){}
	};
	
public:
    vector<string> findLongestSubarray(vector<string>& array) {
		unordered_map<int,Node> m;
		int count=0;
		int begin=-1,len=0;
		Node tem;
		for(int i=0;i<array.size();++i)
		{
			isalphbat(array[i]) ? count++ : count--;	
			if(count==0)
			{
				len=i+1;
			}
			tem=m[count];
			if(tem.max<i)
			{
				m[count].max=i;
			}
			if(tem.min>i)
			{
				m[count].min=i;
			}
		}
		
		for(auto pair : m)
		{
			int len_tem=pair.second.max-pair.second.min;
			if(len_tem>len || len_tem==len && pair.second.min<begin)
			{
				begin=pair.second.min;
				len=len_tem;
			}
		}
		
		vector<string> res;
		for(int i=1;i<=len;++i)
		{
			res.push_back(array[begin+i]);
		}
		
		return res;
    }
    
    bool isalphbat(string str)
    {
    	if( (str>="A" && str<="Z") || (str>="a" && str<="z") )
    	{
    		return true;
		}
		return false;
	} 
};


int main()
{
	return 0;
}
